<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>物业管理系统</title>
    <base href="<%=basePath%>"> 
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/vivo.css">
    <link rel="stylesheet" href="css/cmxform.css">
	
	<script src="js/jquery-1.11.1.js"></script>
    <script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
    <script type="text/javascript" src="js/layer/layer/layer.js"></script> 
    <script type="text/javascript" src="js/sharefunction.js"></script>
	<script type="text/javascript">
		
		$.validator.setDefaults({
		    submitHandler: function() {
		      	saveDocument();
		    }
		});
		
		$(document).ready(function() {
		    $("#commentForm").validate({
		    	errorPlacement: function(error, element) {
					// Append error within linked label
					$( element ).next().append( error );
				},
				errorElement: "span",
				messages: {
					typeName: {
						required: " 必需字段!",
						minlength: " (不能少于 3 个字母)"
					}
				}
				
		    });
		});
		
		function saveDocument(){
			var id=$("#id").val();
			var reason=$("#reason").val();
			
			layer.confirm("确定归档吗？",{icon:3},function(i){
				var url="project/roomInfo/editArchive";
				jQuery.ajax({
				    type:"post",
				    async:false,
				    url:url,
			        dataType:"json",
			        data:{reason:reason,id:id},
				    success:function(data){
				       if(data.success){
				    		window.parent.layer.msg('归档成功！');
							window.parent.gridObj.refreshPage();
							closeLayer();
			        	}else{
			        		layer.alert(data.msg,{icon:7});
			        	}
				    }
		   		});
			});
		}
	</script>
	
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="get" action="">
		<div style="padding:20px">
		
		<div class="panel panel-default">
   			<div class="panel-body">
			<table cellpadding="10" cellspacing="5" class="mytable">
				<tr>
					<td width="90">归档原因</td>
			    			<td colspan="3">
			    				<textarea rows="3" cols="70" type="text" name="reason" id="reason" ></textarea>
			    				<span></span>
			    			</td>

				</tr>
			</table>
			</div>
			</div>
			<div style="width:100%;text-align:center; padding-top:20px"> 
				<button class="btn btn-primary radius" type="submit" > 保 存</button> 
				 <a class="btn btn-default radius" onClick="closeLayer();"> 取 消 </a> 
		    	  <br/><br/>
	    	</div> 
	    	 
		</div>
		
		<input id="id" name="id" type="hidden" value="${id}"/>
		</form>
  	</body>
  	
   </html>
  	
